<?php
declare (strict_types=1);

namespace app\serviceapp;

use app\model\MatchParam;
use app\model\TLabel;
use app\model\TUserMatchParam;
use app\traits\ServiceTrait;
use app\util\JwtUtil;
use app\service\AuthGroupService;
use think\facade\Db;

/**
 * 用户匹配
 * Class TUserMatchParamService
 * @package app\service
 */
class UserMatchParamService
{
    //仓库，带命名空间
    public static $repository = 'app\repository\TUserMatchParamRepository';

    use ServiceTrait;

    /**
     * 根据labelId获取分类ID以及groupId
     * @param $labelIdArr
     */
    public static function getSubCidAndGroupIdByLabelId($labelIdArr)
    {
        // 列表
        $table = TUserMatchParam::$_table;
        $cidGroupIds = Db::table($table)->where([['label_id', 'in',  $labelIdArr]])->column('sub_category_id, match_group_id');
        if (empty($cidGroupIds)) {
            return [];
        }
        $goods = GoodsMatchParamService::getGoodsIdByCidAndGroupId($cidGroupIds);
        return $goods;
    }
}
